<template>
    <view>
        <view v-if="value1 == 0">
            <view class="list">
                <view class="item" v-for="(item, index) in list" :key="index">
                    <view class="info">
                        <view class="name">车牌号：{{ item.number }}</view>
                    </view>


                    <view class="info" style="padding-bottom: 20rpx;">
                        <view class="name">创建时间：{{ item.createtime }}</view>
                    </view>
                    <view class="btn">
                        <view @click="toEdit(item)">编辑</view>
                        <view @click="del(item.id)">删除</view>
                    </view>
                </view>
            </view>
            <view style="margin-top: 300rpx;" v-if="list.length == 0">
                <u-empty mode="data" text="暂无数据～">
                </u-empty>
            </view>
            <view class="add" @click="add">+</view>
        </view>
        <view class="bottom">
            <u-tabbar :value="value1" @change="change1" :fixed="false" :placeholder="false"
                :safeAreaInsetBottom="false">
                <u-tabbar-item text="车队队员" icon="account"></u-tabbar-item>
                <u-tabbar-item text="计算信息" icon="file-text"></u-tabbar-item>
            </u-tabbar>
        </view>
    </view>
</template>

<script>
import { vihiclelist, vihicledelete } from "@/api/user.js"
export default {
    components: {},
    props: {},
    data() {
        return {
            value1: 0,
            page: 1,
            pagesize: 10,
            type: '',
            list: [],
        };
    },
    watch: {},
    methods: {
        change1(e) {
            this.value1 = e
        },
        add() {
            uni.navigateTo({ url: '/pages/manufacturer/addCart' })
        },
        getList() {
            vihiclelist({
                page: this.page,
                pageSize: this.pageSize
            }).then(res => {
                console.log(res.data)
                if (this.page == 1) {
                    this.list = res.data
                } else {
                    this.list = this.list.concat(res.data)
                }
            })
        },
        toEdit(item) {
            uni.navigateTo({ url: '/pages/manufacturer/addCart?type=edit&info=' + encodeURIComponent(JSON.stringify({ id: item.id, number: item.number, user_id: item.user_id })) })
        },
    },
    onShow() {
        this.getList()
    },
    onLoad(option) {
        console.log(option)
    },
};
</script>
<style scoped lang='scss'>
.bottom {
    position: fixed;
    width: 100%;
    bottom: 0;
}

.list {
    width: 94%;
    margin: auto;
    margin-top: 30rpx;
}

.item {
    width: 100%;
    height: 136px;
    background: #FFFFFF;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.3);
    border-radius: 12px 12px 12px 12px;
    margin-top: 30rpx;

    .info {
        width: 94%;
        margin: auto;
        display: flex;
        padding-top: 20rpx;

        .name {
            width: 90%;
            font-size: 30rpx;
            font-weight: 600;
        }

        .status {
            font-size: 28rpx;
            font-weight: 600;
        }

        .a {
            color: green;
        }

        .b {
            color: #dd524d;
        }
    }

    .btn {
        display: flex;
        margin-top: 30rpx;

        view:nth-child(1) {
            width: 125px;
            height: 46px;
            background: #007aff;
            border-radius: 10px 10px 10px 10px;
            border: 1px solid #D9D9D9;
            margin: auto;
            text-align: center;
            line-height: 46px;
            color: #fff;
        }

        view:nth-child(2) {
            width: 125px;
            height: 46px;
            background: #dd524d;
            border-radius: 10px 10px 10px 10px;
            border: 1px solid #D9D9D9;
            margin: auto;
            text-align: center;
            line-height: 46px;
            color: #fff;
        }
    }

}

.add {
    width: 80rpx;
    height: 80rpx;
    border-radius: 50rpx;
    background-color: $uni-color-primary;
    position: fixed;
    bottom: 120rpx;
    font-size: 44rpx;
    text-align: center;
    line-height: 80rpx;
    color: #fff;
    right: 30rpx;
}
</style>